package com.ouc.dataMange.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ouc.common.annotation.Log;
import com.ouc.common.core.controller.BaseController;
import com.ouc.common.core.domain.AjaxResult;
import com.ouc.common.enums.BusinessType;
import com.ouc.dataMange.domain.SysDataSet;
import com.ouc.dataMange.service.ISysDataSetService;
import com.ouc.common.utils.poi.ExcelUtil;
import com.ouc.common.core.page.TableDataInfo;

/**
 * dataSetController
 *
 * @author ouc
 * @date 2025-07-14
 */
@RestController
@RequestMapping("/dataMange/dataSet")
public class SysDataSetController extends BaseController {
  @Autowired
  private ISysDataSetService sysDataSetService;

  /**
   * 查询dataSet列表
   */
//  @PreAuthorize("@ss.hasPermi('dataMange:dataSet:list')")
  @GetMapping("/list")
  public TableDataInfo list(SysDataSet sysDataSet) {
    startPage();
    List<SysDataSet> list = sysDataSetService.selectSysDataSetList(sysDataSet);
    return getDataTable(list);
  }

  /**
   * 导出dataSet列表
   */
  @PreAuthorize("@ss.hasPermi('dataMange:dataSet:export')")
  @Log(title = "dataSet", businessType = BusinessType.EXPORT)
  @PostMapping("/export")
  public void export(HttpServletResponse response, SysDataSet sysDataSet) {
    List<SysDataSet> list = sysDataSetService.selectSysDataSetList(sysDataSet);
    ExcelUtil<SysDataSet> util = new ExcelUtil<SysDataSet>(SysDataSet.class);
    util.exportExcel(response, list, "dataSet数据");
  }

  /**
   * 获取dataSet详细信息
   */
  @PreAuthorize("@ss.hasPermi('dataMange:dataSet:query')")
  @GetMapping(value = "/{id}")
  public AjaxResult getInfo(@PathVariable("id") Integer id) {
    return success(sysDataSetService.selectSysDataSetById(id));
  }

  /**
   * 新增dataSet
   */
  @PreAuthorize("@ss.hasPermi('dataMange:dataSet:add')")
  @Log(title = "dataSet", businessType = BusinessType.INSERT)
  @PostMapping
  public AjaxResult add(@RequestBody SysDataSet sysDataSet) {
    return toAjax(sysDataSetService.insertSysDataSet(sysDataSet));
  }

  /**
   * 修改dataSet
   */
  @PreAuthorize("@ss.hasPermi('dataMange:dataSet:edit')")
  @Log(title = "dataSet", businessType = BusinessType.UPDATE)
  @PutMapping
  public AjaxResult edit(@RequestBody SysDataSet sysDataSet) {
    return toAjax(sysDataSetService.updateSysDataSet(sysDataSet));
  }

  /**
   * 删除dataSet
   */
  @PreAuthorize("@ss.hasPermi('dataMange:dataSet:remove')")
  @Log(title = "dataSet", businessType = BusinessType.DELETE)
  @DeleteMapping("/{ids}")
  public AjaxResult remove(@PathVariable Long[] ids) {
    return toAjax(sysDataSetService.deleteSysDataSetByIds(ids));
  }
}
